package com.xf.micro.core.filter.chain;

import com.xf.micro.core.filter.context.FilterContext;
import com.xf.micro.core.filter.filters.HeadFilter;
import com.xf.micro.core.filter.LinkedCoreFilter;

/**
 * @author zouxf
 * @date 2023/12/26 16:43
 * @description
 */
public class CoreFilterChain extends LinkedCoreFilter {

    private LinkedCoreFilter head = new HeadFilter();

    private LinkedCoreFilter end = head;

    public CoreFilterChain() {

    }

    @Override
    public void doFilter(FilterContext filterContext) {
        head.doFilter(filterContext);
    }

    public void addLast(LinkedCoreFilter coreFilter) {
        end.setNext(coreFilter);
        end = coreFilter;
    }
}
